
<template>
  <div>
    <router-view></router-view>
    <show-error ref="errorDialog"></show-error>
  </div>
</template>


<script>

import { ElMessageBox } from 'element-plus'
import ShowError from './views/ErrorMsg.vue'
export default {
  name: "app",
  data(){
    return{
      dialogVisible : false,
      errorMsg:"",
    }

  },
  mounted() {
    // 注册事件监听器时使用相同的函数引用
    this.handleGlobalError = (event) => {

      this.$refs.errorDialog.show(event.detail); // 调用 showError 方法
      // ShowError.showError(event.detail,true)
      // 在这里显示 Element Plus 的 Dialog 弹窗
      
    };
    // 监听全局事件
    //console.log("创建全局事件"),
      window.addEventListener("errorOccurred", this.handleGlobalError);
  },
  beforeDestroy() {
    // 在组件销毁前，移除事件监听
    window.removeEventListener("errorOccurred", this.handleGlobalError);
  },
  components: { 
    ShowError,
   },
};

</script>


<style lang="scss">
@import "./assets/style/reset.css";
@import "./assets/style/index.scss";
</style>
